package botcraft.gui;

import java.awt.SplashScreen;
import java.lang.reflect.InvocationTargetException;
import java.util.ResourceBundle;

import javax.swing.SwingUtilities;

import botcraft.Configuration;

public abstract class GuiApplication implements Runnable {
	private static final String RESOURCE_BUNDLE = "i18n/botcraft";
	
	protected final Configuration configuration;

	public static void invoke(final GuiApplication guiApplication) throws InterruptedException, InvocationTargetException {
		try {
			SwingUtilities.invokeAndWait(guiApplication);
		} finally {
			final SplashScreen splashScreen = SplashScreen.getSplashScreen();
			if (splashScreen != null)
				splashScreen.close();
		}
	}
	
	protected GuiApplication() {
		configuration = new Configuration();
	}

	protected ResourceBundle getResourceBundle() {
		return ResourceBundle.getBundle(RESOURCE_BUNDLE, configuration.getLocale());
	}
}
